/**
 * 
 */
package com.ccqlk.attendance.repository.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ccqlk.attendance.model.Department;
import com.ccqlk.attendance.repository.dbservice.DepartmentMapper;
import com.ccqlk.attendance.repository.service.base.BaseServiceImpl;
import com.google.common.collect.Maps;

/**
 * Copyright 2015-2018 重庆鲁控科技有限公司<br>
 * 文件标题: DepartmentService<br>
 * 文件说明: 部门<br>
 * @author ZhangYinxian 348893009@qq.com<br>
 * 创建时间 2016年5月27日 上午11:14:53<br>
 */
@Service
public class DepartmentService extends BaseServiceImpl<Department, Integer> {

	private DepartmentMapper departmentMapper;
	
	@Autowired
	public DepartmentService(DepartmentMapper departmentMapper) {
		super(departmentMapper);
		this.departmentMapper = departmentMapper;
	}

	/**
	 * @return
	 */
	public Map<String, Department> map() {
		List<Department> departments = selectAll();
		if (departments!=null && departments.size()>0) {
			Map<String, Department> map = Maps.newHashMap();
			for (Department department : departments) {
				map.put(department.getCode(), department);
			}
			return map;
		}
		return null;
	}

}
